//
//  YQPLogicsInfoCell.m
//  MuYing
//
//  Created by caominglei on 2020/6/8.
//  Copyright © 2020 TBB. All rights reserved.
//

#import "YQPLogicsInfoCell.h"

@implementation YQPLogicsInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpSuviews];

    }
    return self;
}

- (void)setUpSuviews
{
    _signImage = UIImageView.new;
    [self.contentView addSubview:_signImage];
    [_signImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.height.mas_equalTo(22);
//        make.top.mas_equalTo(5);
//        make.left.mas_equalTo(15);
        make.width.height.mas_equalTo(6);
        make.left.mas_equalTo(23);
        make.top.mas_equalTo(25);
    }];
    
    _labStatus = UILabel.new;
    _labStatus.textColor = HexColor(0x999999);
    _labStatus.numberOfLines = 0;
    _labStatus.font = kSystemMedium(10);
    [self.contentView addSubview:_labStatus];
    [_labStatus mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.signImage.mas_right).offset(8);
        make.top.mas_equalTo(self.signImage.mas_top).offset(-5);
        make.right.mas_equalTo(-15);
//        make.bottom.mas_equalTo(-10);
    }];
    
    _portraitImage = UIImageView.new;
    _portraitImage.backgroundColor = HexColor(0xEAEAEA);
    [self.contentView addSubview:_portraitImage];
    [_portraitImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(1);
        make.top.mas_equalTo(self.signImage.mas_bottom).offset(10);
        make.left.mas_equalTo(self.signImage.mas_left).offset(3);
        make.height.mas_equalTo(50);
//        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-5);
    }];

}

/// checkpointStatus transit-运输中 delivered-已签收
/// @param model <#model description#>
- (void)setModel:(YQPLogincsEntityModel *)model
{
    _model = model;
    
    [self.labStatus rz_colorfulConfer:^(RZColorfulConferrer * _Nonnull confer) {
        confer.text(model.statusDescription).textColor(HexColor(0x999999)).font(kSystemMedium(10));
        confer.text(NSStringFormat(@"\n%@",model.date)).textColor(HexColor(0x999999)).font(kSystemMedium(10));

    }];
    
    NSMutableParagraphStyle *style = NSMutableParagraphStyle.new;
    style.lineSpacing = 2;
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:self.labStatus.text];
    [attr addAttributes:@{NSParagraphStyleAttributeName:style} range:NSMakeRange(0, self.labStatus.text.length)];
    self.labStatus.attributedText = attr;
//    self.labStatus.text = NSStringFormat(@"%@\n%@",model.statusDescription,model.date);;
    
    if ([model.checkpointStatus isEqualToString:@"delivered"]) {//签收
        self.signImage.image = IMAGE_NAMED(@"sign_icon");
    }else if ([model.checkpointStatus isEqualToString:@"transit"]) {//运输中
        self.signImage.image = IMAGE_NAMED(@"sign_gray");
    }else if ([model.checkpointStatus isEqualToString:@"pickup"]) {//到达待取
        self.signImage.image = IMAGE_NAMED(@"pickup");
//        [self.signImage mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.width.height.mas_equalTo(6);
//            make.left.mas_equalTo(23);
//            make.top.mas_equalTo(15);
//        }];
        
        [self.portraitImage mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.signImage.mas_left).offset(3);
        }];
    }

}
@end
